<template>
    <div>
        <center>
            <h2>用户注册</h2>
        <table>
            <tr>
                <td>用户名：</td>
                <td><input type="text" v-model="user"></td>
            </tr>
            <tr>
                <td>真实姓名：</td>
                <td><input type="text" v-model="name"></td>
            </tr>
            <tr>
                <td>头像上传：</td>
                <td><input type="file"></td>
            </tr>
              <tr>
                <td>密码：</td>
                <td><input type="password" v-model="pwd"></td>
            </tr>
            <tr>
                <td>手机号码：</td>
                <td><input type="text" v-model="tel"></td>
            </tr>
            <tr>
                <td>电子邮箱：</td>
                <td><input type="text" v-model="email"></td>
            </tr>
            <tr>
                <td></td>
                <td><button @click="btn">注册</button></td>
                <td><a href="#/test">登录</a></td>
            </tr>
        </table>
        </center>
    </div>
</template>
<script>
export default {
    data() {
        return {
             user:"",
             name:"",
             logo:"",
             tel:"",
             email:"",
             pwd:""
        }
    },
    methods: {
        btn(){
            let that = this
            let formData = new window.FormData()
            let files = document.querySelector('input[type=file]').files[0]
            formData.append('logo',files)
            formData.append('user',this.user)
            formData.append('name',this.name)
            formData.append('tel',this.tel)
            formData.append('email',this.email)
            formData.append('pwd',this.pwd)

            this.$axios({
                url:"http://localhost/zice3/public/api/store",
                data:formData,
                method:'post',
                headers:{
                   'Content-Type':"multipart/form-data"
                }
            })
            .then(function(res){
                alert(res.data.msg)
                that.$router.push({
                    path:'/Test'
                })
            })

        }
    },
}
</script>